package tripleo.framework.svr.storage2;

import java.io.*;
import java.util.Random;

import tripleo.fs.File;
import junit.framework.TestCase;

public class IStorageServer2Test1 extends TestCase {

	/*
	 * Test method for 'tripleo.framework.svr.storage2.IStorageServer2.createFile(String, File)'
	 */
	public void testCreateFile() throws Exception {
		ss2 ass = new ss2("test2");
		File fr = new File("test2/4--00");
		FileOutputStream fp = fr.fos();
		Random rr = new Random();
		PrintStream ps = new PrintStream(fp);
		for (int i = 0; i < 100; i++) {
			ps.println(rr.nextInt());
		}
		fp.close();
	}

	/*
	 * Test method for 'tripleo.framework.svr.storage2.IStorageServer2.deleteFile(String)'
	 */
	public void testDeleteFile() {

	}

	/*
	 * Test method for 'tripleo.framework.svr.storage2.IStorageServer2.readFile(String, long)'
	 */
	public void testReadFile() {

	}
	public void testOne() throws Exception {
		ss2 ass = new ss2("test2");
		File fr = new File("test2/4--01");
		FileOutputStream fp = fr.fos();
		final String msg = "Hello, World";
		fp.write(msg.getBytes());
		fp.close();
		ass.createFile("cap1", fr);
		File f2=ass.readFile("cap1", 0);
		FileInputStream fp2 = f2.fis();
		byte[] bs=new byte[(int) f2.length()];
		fp2.read(bs);
		String s2 = new String(bs);
		assert msg.equals(bs);
	}

}
